package juc;

import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created with IDEA
 * author:Yhk
 * Date:2019/7/9
 * Time:8:37 AM
 */
public class List {
    public static void main(String[] args) throws Exception {
        // 异步处理
        CopyOnWriteArrayList<String> all = new CopyOnWriteArrayList<String>();
        for (int x = 0; x < 20; x++) {
            int temp = x;
            new Thread(() -> {
                for (int y = 0; y < 30; y++) {
                    all.add(Thread.currentThread().getName()
                            + " - " + temp + " - " + y);
                    System.out.println(all);
                }
            }).start();
        }
    }
}
